import requests
import json
HEADERS = {
    "Origin": "http://stock.quote.stockstar.com/600000.shtml",
    "Referer": "http://stock.quote.stockstar.com/600000.shtml",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36"
}


def getDayK():
    url = 'http://flashdata2.jrj.com.cn/history/js/share/300043/other/dayk_ex.js?random=1571470663130'
    response = requests.get(url, headers=HEADERS).text
    data = str(response).split('"hqs":[')[1].replace(']}', '')
    data = data.split('"factor"')[0]
    dataArr = data.split('],[')
    for item in dataArr:
        # item.replace('[', '').replace(']', '')
        print(item)

def getWeekK():
    url = 'http://flashdata2.jrj.com.cn/history/js/share/300300/other/weekk.js?random=1571470590665'
    response = requests.get(url, headers=HEADERS).text
    data = str(response).split('"hqs":[')[1].replace(']}', '')
    dataArr = data.split('],[')
    print(data)
    for item in dataArr:
        item.replace('[','').replace(']','')
        print(item)

if __name__ == '__main__':
    getWeekK()